function CMain(oData) {
    var _bUpdate;
    var _iCurResource = 0;
    var RESOURCE_TO_LOAD = 0;
    var _iState = STATE_LOADING;
    var _oData;
    var _oPreloader;
    var _oMenu;
    var _oHelp;
    var _oGame;
    var _oCongratulations;

    this.initContainer = function () {
        createjs.CSSPlugin.install(createjs.Tween);

        var canvas = document.getElementById("gameView");
        s_oStage = new createjs.Stage(canvas);
        createjs.Touch.enable(s_oStage);
        s_oStage.preventSelection = false;

        s_bMobile = jQuery.browser.mobile;
        if (s_bMobile === false) {
            s_oStage.enableMouseOver(20);
            $('body').on('contextmenu', '#canvas', function (e) {
                return false;
            });
        }

        if (navigator.userAgent.match(/Windows Phone/i)) {
            DISABLE_SOUND_MOBILE = true;
        }

        // s_oSpriteLibrary = new CSpriteLibrary();
        s_oSpriteLibrary = new createjs.LoadQueue();
        s_oSpriteLibrary.installPlugin(createjs.Sound);

        // 资源列表
        s_oSpriteLibrary.loadManifest([
            {
                id: "bg",
                src: "./img/bg.png"
            }, {
                id: "audio_icon",
                src: "./img/audio_icon.png"
            }, {
                id: "blackboard",
                src: "./img/blacktianzi.png"
            }, {
                id: "ban",
                src: "./img/ban.png"
            }, {
                id: "next",
                src: "./img/next.png"
            }, {
                id: "pre",
                src: "./img/pre.png"
            }, {
                id: "setting",
                src: "./img/setting.png"
            }, {
                id: "shengyin",
                src: "./img/shengyin.png"
            }, {
                id: "click",
                src: "./mp3/click.mp3"
            }, {
                id: "hemiao",
                src: "./img/hemiao.png"
            }, {
                id: "lajiao",
                src: "./img/lajiao.png"
            }, {
                id: "putao",
                src: "./img/putao.png"
            }, {
                id: "shiliu",
                src: "./img/shiliu.png"
            }, {
                id: "lefttop",
                src: "./img/lefttop.png"
            }, {
                id: "righttop",
                src: "./img/righttop.png"
            }, {
                id: "leftbottom",
                src: "./img/leftbottom.png"
            }, {
                id: "rightbottom",
                src: "./img/rightbottom.png"
            }, {
                id: "zhu",
                src: "./img/zhu.png"
            }
        ]);

        //文件加载进程
        s_oSpriteLibrary.on("progress", function() {
            document.querySelector("#load-msg").innerText = "加载中"+parseInt(s_oSpriteLibrary.progress*100)+"%...";
            //加载完成把进度条隐藏
            if(parseInt(s_oSpriteLibrary.progress*100) === 100){
                document.querySelector("#load-msg").style.display = "none";
                $('body')
                    .css("background", "url(img/bg.png)")
                    .css("background-size", "cover")
                ;
            }
            //console.log("Progress:", parseInt(_this.queue.progress*100), event.progress);
        });
        //文件加载完成执行
        s_oSpriteLibrary.addEventListener("complete", function () {
            s_oMain.gotoGame();
        });

        _bUpdate = true;

        createjs.Ticker.addEventListener("tick", this._update);
        createjs.Ticker.setFPS(30);
    };

    this.gotoGame = function () {
        _oGame = new CGame();
        _iState = STATE_GAME;
    };

    this.stopUpdate = function(){
        _bUpdate = false;
        createjs.Ticker.paused = true;
        $("#block_game").css("display","block");
		createjs.Sound.setMute(true);
    };

    this.startUpdate = function(){
        s_iPrevTime = new Date().getTime();
        _bUpdate = true;
        createjs.Ticker.paused = false;
        $("#block_game").css("display","none");

		if(s_bAudioActive){
			createjs.Sound.setMute(false);
		}
    };

    this._update = function (event) {
        if (_bUpdate === false) {
            return;
        }

        if (s_oLeftTop) {
            s_oLeftTop.flipUpdate();
        }
        if (s_oRigthTop) {
            s_oRigthTop.flipUpdate();
        }
        if (s_oLeftBottom) {
            s_oLeftBottom.flipUpdate();
        }
        if (s_oRightBottom) {
            s_oRightBottom.flipUpdate();
        }
        s_oStage.update(event);
    };

    s_oMain = this;

    _oData = oData;
    this.initContainer();
}

var s_bMobile;
var s_bAudioActive = true;
var s_iPrevTime = 0;

var s_oStage;
var s_oMain;
var s_oSpriteLibrary;
var s_oSoundTrack;
var s_oLeftTop;
var s_oLeftBottom;
var s_oRigthTop;
var s_oRightBottom;